package studio.raptor.ddal.core.engine.plan.node.impl.ddl;

import studio.raptor.ddal.config.model.shard.VirtualDb;
import studio.raptor.ddal.core.engine.ProcessContext;
import studio.raptor.ddal.core.engine.plan.node.ProcessNode;
import studio.raptor.ddal.core.router.result.FullRouteResult;
import studio.raptor.ddal.core.router.result.RouteNode;
import studio.raptor.ddal.core.router.result.RouteResult;

/**
 * 处理 "drop index"  DDL操作
 *
 * @author liujy
 * @since 1.0
 */
public class HandleDDLIndexDrop extends ProcessNode{

  @Override
  protected void execute(ProcessContext context) {
    VirtualDb virtualDb = context.getVirtualDb();
    RouteResult routeResult = new FullRouteResult();
    routeResult.setShards(virtualDb.getShards());
    routeResult.setDbShard(virtualDb.getShards().allShardNames());
    routeResult.setParameters(context.getStatementContext().getSqlParameters());
    for (RouteNode routeNode : routeResult.getRouteNodes()){
      routeNode.setFinalSql(context.getStatementContext().getOriginSql());
    }
    context.getStatementContext().setRouteResult(routeResult);
  }
}
